#pragma once


#include "y2kMain.h"


y2kMain main;


LRESULT CALLBACK WinProc( HWND hWnd, unsigned int unMessage, WPARAM wParam, LPARAM lParam );


int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdParam, int nCmdShow )
{	
	if( main.create( hInstance, WinProc ) )
	{
		main.initialize();
	}


	MSG message;

	while( GetMessage( &message, 0, 0, 0 ) )
	{
		TranslateMessage( &message );
		DispatchMessage( &message );

		main.update();
		main.render();
	}

	main.clear();


	return (int)message.wParam;
}


LRESULT CALLBACK WinProc( HWND hWnd, unsigned int unMessage, WPARAM wParam, LPARAM lParam )
{
	if( !main.run_message( unMessage, wParam, lParam ) )
	{
		switch( unMessage )
		{
		case WM_DESTROY :
			{
				PostQuitMessage( 0 );
			}
			return 0;
		}
	}	

	return ( DefWindowProc( hWnd, unMessage, wParam, lParam ) );
}